% -*- coding: utf-8 -*-
% !TEX program = lualatex
\documentclass[oneside]{book}

\input{manual.sty}
\CodeHigh{lite}
\setcounter{chapter}{1}

\begin{document}

% \chapter{Basic Interfaces}
\chapter{用户接口}
\label{chap:basic}

% \section{Old and New Interfaces}
\section{新旧用户接口}

% With \verb!tabularray! package, you can change the styles of tables via old interfaces or new interfaces.
在 \verb!Tabularray! 宏包中，通过用户接口可以实现表格样式控制。

% The old interfaces consist of some table commands inside the table contents.
% Same as \verb!tabular! and \verb!array! environments,
% all table commands \textcolor{red3}{must} be put at the beginning ot the cell text.
% Also, new table commands \textcolor{red3}{must} be defined with \verb!\NewTableCommand!.
旧的用户接口由嵌入表格内容中的一系列命令构成。
此时，与\verb!tabular!和\verb!array!环境类似，
所有的命令\textcolor{red3}{必须}置于单元格文本内容之前。
另外，如果需要新表格命令，
则\textcolor{red3}{必须}使用 \verb!\NewTableCommand! 命令进行定义。


% The new interfaces consist of some options inside the mandatory argument,
% hence totally separating the styles and the contents of tables.
新的用户接口由\verb!tblr!环境的必选参数中的keyval实现，
因此，使用新用户接口可以实现表格内容与格式的完全分离。

新旧接口的对应关系如\ref{key:interface}所示。

\begin{newtblr}[
  % caption = {Old Interfaces and New Interfaces},
  caption = {新旧用户接口},
  label = {key:interface},
]{verb}
  % Old Interfaces                                 & New Interfaces          \\
  \relax{}旧接口                                 & \relax{}新接口          \\
  \verb!\SetHlines!                              & \K{hlines}              \\
  \verb!\SetHline!, \verb!\hline!, \verb!\hborder!, \verb!\cline!
                                                 & \K{hline}, \K{hborder}, \K{rowspec}  \\
  \verb!\SetVlines!                              & \K{vlines}              \\
  \verb!\SetVline!, \verb!\vline!, \verb!\vborder!, \verb!\rline!
                                                 & \K{vline}, \K{vborder}, \K{colspec}  \\
  \verb!\SetCells!                               & \K{cells}               \\
  \verb!\SetCell!                                & \K{cell}                \\
  \verb!\SetRows!                                & \K{rows}                \\
  \verb!\SetRow!                                 & \K{row}, \K{rowspec}    \\
  \verb!\SetColumns!                             & \K{columns}             \\
  \verb!\SetColumn!                              & \K{column}, \K{colspec} \\
\end{newtblr}

% \section{Hlines and Vlines}
\section{表格横线和竖线}

% All available keys for hlines and vlines are described in Table \ref{key:hvline}.
表格横线(\verb!hlines!)和竖线(\verb!vlines!)选项所有有效键及其键值见表\ref{key:hline}和表\ref{key:vline}.。

% \begin{spectblr}[
%   caption = {Keys for Hlines and Vlines},
%   label = {key:hvline},
%   remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
% ]{}
%   Key & Description and Values & Initial Value \\
%   \underline{\K{dash}} & dash style: \V{solid}, \V{dashed} or \V{dotted} & \V{solid} \\
%   \K{text}             & replace hline/vline with text (like \V{!} specifier in \K{colspec}) & None \\
%   \underline{\K{wd}}   & rule width dimension & None \\
%   \underline{\K{fg}}   & rule color name & None \\
% \end{spectblr}
\begin{spectblr}[
  caption = {Hlines的键值},
  label = {key:hline},
  remark{注意} = {多数情况下，对于带有下划线的键，可以省略键名而只给出键值。}
]{}
  键 & 说明与可选键值 & 初始值 \\
  \underline{\K{dash}} & 线型：\V{solid}、 \V{dashed} 或 \V{dotted} & \V{solid} \\
  \K{text}             & 用文本替换hline(与在\K{rowspec}中将横线指定为为\V{!}一样) & \None \\
  \underline{\K{wd}}   & 线宽 & \V{0.4pt} \\
  \underline{\K{fg}}   & 表线颜色 & \None \\
  \K{leftpos}          & 左侧的相交或截断位置  & \V{1} \\
  \K{rightpos}         & 右侧的相交或截断位置 & \V{1} \\
  \K{endpos}           & 是否修正最左列左边/最右列右边位置 & \V{false} \\  
  % \K{abovespace}       & 设置前一行的 \V{belowsep} (见表 \ref{key:row}) & \V{2pt} \\
  % \K{belowspace}       & 设置当前行的 \V{abovesep} (见表 \ref{key:row}) & \V{2pt} \\
  % \K{abovespace+}      & 前一行的 \V{belowsep} 增加量 & \None \\
  % \K{belowspace+}      & 当前行的 \V{abovesep} 增加量 & \None \\
\end{spectblr}
\vspace{-2em}
\begin{spectblr}[
  caption = {Vlines的键值},
  label = {key:vline},
  remark{注意} = {多数情况下，对于带有下划线的键，可以省略键名而只给出键值。}
]{}
  键 & 说明与可选键值 & 初始值 \\
  \underline{\K{dash}} & 线型: \V{solid}、 \V{dashed} 或 \V{dotted} & \V{solid} \\
  \K{text}             & 用文本替换vline (与在 \K{colspec}中将竖线指定为 \V{!}一样 ) & \None \\
  \underline{\K{wd}}   & 线宽 & \V{0.4pt} \\
  \underline{\K{fg}}   & 颜色 & \None \\
  \K{abovepos}         & 上侧的相交或截断位置 & \V{0} \\
  \K{belowpos}         & 下侧的相交或截断位置 & \V{0} \\
\end{spectblr}

% \subsection{Hlines and Vlines in New Interfaces}
\subsection{新接口中的表格横线与竖线}

% Options \verb!hlines! and \verb!vlines! are for setting all hlines and vlines, respectively.
% With empty value, all hlines/vlines will be solid.
\verb!hlines! 和 \verb!vlines! 分别用于设置表格所有横线与竖线样式。
如果其键值留空，则会把表格所有横线/竖线都设置为实线。

\begin{demohigh}
\begin{tblr}{hlines,vlines}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
\end{tblr}
\end{demohigh}

% With values inside one pair of braces, all hlines/vlines will be styled.
可以在一对大括号中通过指定横线/竖线样式。

\begin{demohigh}
\begin{tblr}{
 hlines = {1pt,solid}, vlines = {red3,dashed},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
\end{tblr}
\end{demohigh}

% Another pair of braces before will select segments in all hlines/vlines.
也可以在大括号前用另一对大括号指定需要设置单元格横线/竖线线段编号。

\begin{demohigh}
\begin{tblr}{
 vlines = {1,3,5}{dashed},
 vlines = {2,4}{solid},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
\end{tblr}
\end{demohigh}

% The above example can be simplified with \verb!odd! and \verb!even! values.
% (More child selectors can be defined with \verb!\NewChildSelector! command.
% Advanced users could read the source code for this.)
以上示例也可以简单地通过指定\verb!odd!和\verb!even!选择算子进行选择
(可使用\verb!\NewChildSelector!命令定义更多选择算子，高级用户请参阅
\verb!Tabularray!源代码，通过模仿定义需要的选择算子)。

\begin{demohigh}
\begin{tblr}{
 vlines = {odd}{dashed},
 vlines = {even}{solid},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
\end{tblr}
\end{demohigh}

% Another pair of braces before will draw more hlines/vlines (in which \verb!-! stands for all line segments).
可以再增加一对大括号用于设置多重横线/竖线(其中，\verb!-! 表示选择所有单元格线段)。

\begin{demohigh}
\begin{tblr}{
 hlines = {1}{-}{dashed},
 hlines = {2}{-}{solid},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
\end{tblr}
\end{demohigh}

注意：\underline{必须}先使用1，然后是2等这样的顺序设置多重横线/竖线。

% Options \verb!hline{i}! and \verb!vline{j}! are for setting some hlines and vlines, respectively.
% Their values are the same as options \verb!hliness! and \verb!vlines!:
\verb!hline{i}!和\verb!vline{j}!键分别用于设置指定的横线/竖线，
\verb!i!或\verb!j!的值与 \verb!hlines!和 \verb!vlines! 的参数含义相同：

\begin{demohigh}
\begin{tblr}{
 hline{1,7} = {1pt,solid},
 hline{3-5} = {blue3,dashed},
 vline{1,5} = {3-4}{dotted},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

% You can use \verb!X!, \verb!Y!, \verb!Z! to denote the last three children, respectively.
% It is especially useful when you are writing long tables:
也可以使用\verb!X!、\verb!Y!和\verb!Z!分别指定最后三条横线/竖线的样式，
这在排版多行/多列表格时特别有用。

\begin{demohigh}
\begin{tblr}{
 hline{1,Z} = {2pt},
 hline{2,Y} = {1pt},
 hline{3-X} = {dashed},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

% Now we show the usage of \verb!text! key by the following example%
% \footnote{Code from \url{https://tex.stackexchange.com/questions/603023/tabularray-and-tabularx-column-separator}.}:
下面的示例演示了 \verb!text! 的使用方式%
\footnote{代码来自 \url{https://tex.stackexchange.com/questions/603023/tabularray-and-tabularx-column-separator}。}：

\begin{demohigh}
\begin{tblr}{
  vlines, hlines,
  colspec = {lX[c]X[c]X[c]X[c]},
  vline{2} = {1}{text=\clap{:}},
  vline{3} = {1}{text=\clap{\ch{+}}},
  vline{4} = {1}{text=\clap{\ch{->}}},
  vline{5} = {1}{text=\clap{\ch{+}}},
}
  Equation & \ch{CH4} & \ch{2 O2} & \ch{CO2} & \ch{2 H2O} \\
  Initial  & $n_1$    & $n_2$     & 0        & 0 \\
  Final    & $n_1-x$  & $n_2-2x$  & $x$      & $2x$ \\
\end{tblr}
\end{demohigh}

% You need to load \verb!chemmacros! package for the \verb!\ch! command.
注意，为使用 \verb!\ch! 命令，必须载入\verb!chemmacros!宏包。

\verb!leftpos! 和 \verb!rightpos! 用于指定hlines的相交或截断位置，
其取值为 \verb!-1! 和 \verb!1!之间的十进制数。
它们的初始值是 \verb!1!.

\begin{center}
\begin{tblr}{width=0.5\textwidth,colspec={rX[l]},hlines}
  -1 & 使用 \V{colsep} 对hline进行截断 \\
   0 & hline仅与第1条vline相交 \\
   1 & hline与所有vlines相交 \\
\end{tblr}
\end{center}

vlines的\verb!abovepos! 和 \verb!belowpos! 键具备类似的含义，
但其初始值为 \verb!0!.

\begin{center}
\begin{tblr}{width=0.5\textwidth,colspec={rX[l]},hlines}
  -1 & 使用 \V{rowsep} 对vline进行截断\\
   0 & vline 仅与第1条hline相交 \\
   1 & vline 与所有hlines相交 \\
\end{tblr}
\end{center}

以下是这四个键的一个应用实例:

\begin{demohigh}
\begin{tblr}{
  hline{1,4} = {1}{-}{},
  hline{1,4} = {2}{-}{},
  hline{2,3} = {1}{-}{leftpos = -1, rightpos = -1},
  hline{2,3} = {2}{-}{leftpos = -1, rightpos = -1},
  vline{1,4} = {abovepos = 1, belowpos = 1},
}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

% There is also an \verb!endpos! option for adjusting \verb!leftpos!/\verb!rightpos!
% for only the leftmost/rightmost column:
\verb!endpos!选项用于设置是否调整最左列的 \verb!leftpos! 或最右列的 \verb!rightpos!：

\begin{demohigh}
\begin{tblr}{
 hline{1,4} = {1}{-}{},
 hline{1,4} = {2}{-}{},
 hline{2,3} = {leftpos = -1, rightpos = -1, endpos},
 vline{1,4} = {abovepos = 1, belowpos = 1},
}
 Alpha   & Beta  & Gamma  \\
 Epsilon & Zeta  & Eta    \\
 Iota    & Kappa & Lambda \\
\end{tblr}
\end{demohigh}

% \subsection{Hlines and Vlines in Old Interfaces}
\subsection{旧接口中的表格横线与竖线}

% The \verb!\hline! command has an optional argument which accepts key-value options.
% The available keys are described in Table \ref{key:hvline}.
可以在\verb!\hline!命令中通过选项指定横线样式，
其有效的键值见表\ref{key:hline}.

\begin{demohigh}
\begin{tblr}{llll}
\hline
 Alpha   & Beta  & Gamma  & Delta \\
\hline[dashed]
 Epsilon & Zeta  & Eta    & Theta \\
\hline[dotted]
 Iota    & Kappa & Lambda & Mu    \\
\hline[2pt,blue5]
\end{tblr}
\end{demohigh}

% The \verb!\cline! command also has an optional argument which is the same as \verb!\hline!.
\verb!\cline!命令的选项与\verb!\hline!相同。

\begin{demohigh}
\begin{tblr}{llll}
\cline{1-4}
 Alpha   & Beta  & Gamma  & Delta \\
\cline[dashed]{1,3}
 Epsilon & Zeta  & Eta    & Theta \\
\cline[dashed]{2,4}
 Iota    & Kappa & Lambda & Mu    \\
\cline[2pt,blue5]{-}
\end{tblr}
\end{demohigh}

% You can use child selectors in the mandatory argument of \verb!\cline!.
也可以在 \verb!\cline! 命令的必选参数中通过选择算子实现行/列选择。

\begin{demohigh}
\begin{tblr}{llll}
\cline{1-4}
 Alpha   & Beta  & Gamma  & Delta \\
\cline[dashed]{odd}
 Epsilon & Zeta  & Eta    & Theta \\
\cline[dashed]{even}
 Iota    & Kappa & Lambda & Mu    \\
\cline[2pt,blue5]{-}
\end{tblr}
\end{demohigh}

% Commands \verb!\SetHline! combines the usages of \verb!\hline! and \verb!\cline!:
\verb!\SetHline!命令是一个组合了 \verb!\hline! 和 \verb!\cline!功能的命令：

\begin{demohigh}
\begin{tblr}{llll}
\SetHline{1-3}{blue5,1pt}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\SetHline{2-4}{teal5,1pt}
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{llll}
\SetHline[1]{1-3}{blue5,1pt}
\SetHline[2]{1-3}{azure5,1pt}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\SetHline[1]{2-4}{teal5,1pt}
\SetHline[2]{2-4}{green5,1pt}
\end{tblr}
\end{demohigh}

% In fact, table command \verb!\SetHline[<index>]{<columns>}{<styles>}! at the beginning of row \verb!i!
% is the same as table option \verb!hline{i}={<index>}{<columns>}{<styles>}!.
本质上, 在第\verb!i!行前使用 \verb!\SetHline[<index>]{<columns>}{<styles>}!命令与

\verb!hline{i}={<index>}{<columns>}{<styles>}!键的作用完全相同。

% Also, table command \verb!\SetHlines[<index>]{<columns>}{<styles>}! at the beginning of some row
% is the same as table option \verb!hlines={<index>}{<columns>}{<styles>}!.
同样，在某些行前使用 \verb!\SetHlines[<index>]{<columns>}{<styles>}!命令与

\verb!hlines={<index>}{<columns>}{<styles>}!键的作用完全相同。

% The usages of table commands \verb!\vline!, \verb!\rline!, \verb!\SetVline!, \verb!\SetVlines!
% are similar to those of \verb!\hline!, \verb!\cline!, \verb!\SetHline!, \verb!\SetHlines!, respectively.
% But normally you don't need to use them.
\verb!\vline!、 \verb!\rline!、 \verb!\SetVline!和 \verb!\SetVlines!命令的使用方法
分别与\verb!\hline!, \verb!\cline!, \verb!\SetHline!, \verb!\SetHlines!的使用方法相同。
但通常情况下，一般不建议直接使用这些命令。

\section{水平和垂直边框}

选项 \verb!hborder{i}! 和 \verb!vborder{j}! 分别与 \verb!hline{i}! 和 \verb!vline{j}!类似，
但它们指定的边框线与hline和vline无关。
所有有效的 \verb!hborder{i}! 和 \verb!vborder{j}!键见表~\ref{key:hborder} 和~\ref{key:vborder}。

\begin{spectblr}[
  caption = {水平边框键},
  label = {key:hborder},
]{}
  键 & 含义 & 初始值 \\
  \K{pagebreak}   & 在该位置分页: \V{yes}, \V{no} or \V{auto}
                    (见第~\ref{chap:long}章) & \V{auto} \\
  \K{abovespace}  & 设置前一行的 \V{belowsep} (见表 \ref{key:row}) & \V{2pt} \\
  \K{belowspace}  & 设置当前行的 \V{abovesep} (见表 \ref{key:row}) & \V{2pt} \\
  \K{abovespace+} & 增加前一行的 \V{belowsep} & \None \\
  \K{belowspace+} & 增加当前行的 \V{abovesep} & \None \\
\end{spectblr}
\vspace{-2em}
\begin{spectblr}[
  caption = {垂直边框键},
  label = {key:vborder},
]{}
  键 & 定义和值 & 初始值 \\
  \K{leftspace}   & 设置前一列的 \V{rightsep} (见表 \ref{key:column}) & \V{6pt} \\
  \K{rightspace}  & 设置当前列的 \V{leftsep} (见表 \ref{key:column}) & \V{6pt} \\
  \K{leftspace+}  & 增加前一列的 \V{rightsep} & \None \\
  \K{rightspace+} & 增加当前列的 \V{leftsep}  & \None \\
\end{spectblr}

进一步来讲，在第\verb!i!行开始处的 \verb!\hborder{<specs>}! 命令与
表格的 \verb!hborder{i}={<specs>}!选项作用相同，
在第\verb!j!列开始处的 \verb!\vborder{<specs>}! 命令与
表格的 \verb!vborder{j}={<specs>}!选项作用相同，

% \section{Cells and Spancells}
\section{单元格与单元格合并选项}

% All available keys for cells are described in Table \ref{key:cell} and Table \ref{key:cellspan}.
单元格所有有效键及键值见表\ref{key:cell}和表 \ref{key:cellspan}.

% \begin{spectblr}[
%   caption = {Keys for the Content of Cells},
%   label = {key:cell},
%   remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
% ]{}
%   Key & Description and Values & Initial Value \\
%   \underline{\K{halign}}
%     & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right)
%     & \V{l} \\
%   \underline{\K{valign}}
%     & vertical alignment: \V{t} (top), \V{m} (middle), \V{b} (bottom),
%       \V{h} (head) or \V{f} (foot)
%     & \V{t} \\
%   \underline{\K{wd}} & width dimension & None \\
%   \underline{\K{bg}} & background color name & None \\
%   \K{fg}    & foreground color name & None \\
%   \K{font}  & font commands & None \\
%   \K{preto} & prepend text to the cell & None \\
%   \K{appto} & append text to the cell & None \\
%   \K{cmd}   & execute command for the cell text & None \\
% \end{spectblr}
\begin{spectblr}[
  caption = {\V{cells}键与键值},
  label = {key:cell},
  remark{注意} = {多数情况下，对于带有下划线的键，可以省略键名而只给出键值。}
]{verb}
  % Key & Description and Values & Initial Value \\
  \relax{}键 & \relax{}说明与可选键值 & \relax{}初始值 \\
  \underline{\K{halign}}
    & 水平对齐方式： \V{l} (left), \V{c} (center), \V{r} (right) 或 \V{j} (justify)
    & \V{j} \\
  \underline{\K{valign}}
    & 垂直对齐方式： \V{t} (top), \V{m} (middle), \V{b} (bottom),
      \V{h} (head)或\V{f} (foot)
    & \V{t} \\
  \underline{\K{wd}} & 宽度 & \None \\
  \underline{\K{bg}} & 背景颜色 & \None \\
  \K{fg}    & 前景颜色 & \None \\
  \K{font}  & 字体命令 & \None \\
  \K{mode}  & 单元格模式: \V{math}, \V{imath}, \V{dmath} or \V{text} & \None \\
  \verb!$!  & 与 \V{mode=math} 相同 & \None \\
  \verb!$$! & 与 \V{mode=dmath} 相同 & \None \\
  \K{cmd}   & 对单元格文本要执行的命令 & \None \\
  \K{preto} & 单元格前导文本 & \None \\
  \K{appto} & 单元格附加文本 & \None \\
\end{spectblr}
\vspace{-2em}
% \begin{spectblr}[
%   caption = {Keys for Multispan of Cells},
%   label = {key:cellspan},
% ]{}
%   Key & Description and Values & Initial Value \\
%   \K{r} & number of rows the cell spans    & 1 \\
%   \K{c} & number of columns the cell spans & 1 \\
% \end{spectblr}
\begin{spectblr}[
  caption = {单元格合并键与键值},
  label = {key:cellspan},
]{}
  键 & 说明与可选键值 & 初始值 \\
  \K{r} & 合并行数    & 1 \\
  \K{c} & 合并列数    & 1 \\
\end{spectblr}

% \subsection{Cells and Spancells in New Interfaces}
\subsection{单元格与单元格合并新接口}

% Option \verb!cells! is for setting all cells.
\verb!cells!键用于设置所有单元格的样式。
\nopagebreak
\begin{demohigh}
\begin{tblr}{hlines={white},cells={c,blue7}}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
\end{tblr}
\end{demohigh}

% Option \verb!cell{i}{j}! is for setting some cells,
% where \verb!i! stands for the row numbers and \verb!j! stands for the column numbers.
\verb!cell{i}{j}!键用于设置指定行列位置单元格的样式，
其中，\verb!i!表示行索引，\verb!j!表示列索引。
\nopagebreak
\begin{demohigh}
\begin{tblr}{
  cell{1}{2-4} = {cmd=\fbox}
}
  Alpha & Beta & Gamma & Delta
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{
 hlines = {white},
 vlines = {white},
 cell{1,6}{odd} = {teal7},
 cell{1,6}{even} = {green7},
 cell{2,4}{1,4} = {red7},
 cell{3,5}{1,4} = {purple7},
 cell{2}{2} = {r=4,c=2}{c,azure7},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

% \subsection{Cells and Spancells in Old Interfaces}
\subsection{单元格与单元格合并旧接口}

% The \verb!\SetCell! command has a mandatory argument for setting the styles of current cell.
% The available keys are described in Table \ref{key:cell}.
\verb!\SetCell!命令的必选参数用于设置当前单元格的样式。
其有效值见表 \ref{key:cell}.

\begin{demohigh}
\begin{tblr}{llll}
\hline[1pt]
 Alpha   & \SetCell{bg=teal2,fg=white} Beta & Gamma \\
\hline
 Epsilon & Zeta & \SetCell{r,font=\scshape} Eta \\
\hline
 Iota    & Kappa & Lambda \\
\hline[1pt]
\end{tblr}
\end{demohigh}

% The \verb!\SetCell! command also has an optional argument for setting the multispan of current cell.
% The available keys are described in Table \ref{key:cellspan}.
 \verb!\SetCell!命令也可以使用可选参数设置当前单元格需要合并的列数和行数。
其有效值见表 \ref{key:cellspan}.

\begin{demohigh}
\begin{tblr}{|X|X|X|X|X|X|}
\hline
 Alpha & Beta & Gamma & Delta & Epsilon & Zeta \\
\hline
 \SetCell[c=2]{c} Eta & 2-2
              & \SetCell[c=2]{c} Iota & 2-4
                              & \SetCell[c=2]{c} Lambda  & 2-6 \\
\hline
 \SetCell[c=3]{c} Nu & 3-2 & 3-3
                      & \SetCell[c=3]{c} Pi & 3-5 & 3-6   \\
\hline
 \SetCell[c=6]{c} Tau & 4-2 & 4-3 & 4-4 & 4-5 & 4-6 \\
\hline
\end{tblr}
\end{demohigh}

\begin{demohigh}
\begin{tblr}{|X|X|X|X|X|X|}
\hline
 Alpha & Beta    & Gamma   & Delta & Epsilon & Zeta \\
\hline
 \SetCell[r=2]{m} Eta
       & Theta   & Iota    & Kappa & Lambda  & \SetCell[r=2]{m} Mu  \\
\hline
 Nu    & Xi      & Omicron & Pi    & Rho     & Sigma \\
\hline
\end{tblr}
\end{demohigh}

% In fact, table command \verb!\SetCell[<span>]{<styles>}! at the beginning of cell at row \verb!i!
% and column \verb!j! is the same as table option \verb!cell{i}{j}={<span>}{<styles>}!.
本质上，在第\verb!i!行、第\verb!j!列的单元格前使用\verb!\SetCell[<span>]{<styles>}!命令与

\verb!cell{i}{j}={<span>}{<styles>}!的作用完全相同。

% Also, table command \verb!\SetCells[<span>]{<styles>}! at the beginning of some cell
% is the same as table option \verb!cells={<span>}{<styles>}!.
同样，表格命令 \verb!\SetCells[<span>]{<styles>}!
与 \verb!cells={<span>}{<styles>}!的作用完全相同。

% \section{Rows and Columns}
\section{行(\V{rows})和列(\V{columns})选项}

% All available keys for rows and columns are described in Table \ref{key:row} and Table \ref{key:column}.
行(\V{rows})和列(\V{columns})选项的键和有效健值见表 \ref{key:row}和表 \ref{key:column}。

% \begin{spectblr}[
%   caption = {Keys for Rows},
%   label = {key:row},
%   remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
% ]{}
%   Key & Description and Values & Initial Value \\
%   \underline{\K{halign}}
%     & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right)
%     & \V{l} \\
%   \underline{\K{valign}}
%     & vertical alignment: \V{t} (top), \V{m} (middle), \V{b} (bottom),
%       \V{h} (head) or \V{f} (foot)
%     & \V{t} \\
%   \underline{\K{ht}} & height dimension & None \\
%   \underline{\K{bg}} & background color name & None \\
%   \K{fg} & foreground color name & None \\
%   \K{font} & font commands & None \\
%   \K{abovesep} & set vertical space above the row & \V{2pt} \\
%   \K{abovesep+} & increase vertical space above the row & None \\
%   \K{belowsep} & set vertical space below the row & \V{2pt} \\
%   \K{belowsep+} & increase vertical space below the row & None \\
%   \K{rowsep} & set vertical space above and below the row & \V{2pt} \\
%   \K{rowsep+} & increase vertical space above and below the row & None \\
%   \K{preto} & prepend text to every cell (like \V{>} specifier in \K{rowspec}) & None \\
%   \K{appto} & append text to every cell (like \V{<} specifier in \K{rowspec}) & None \\
%   \K{cmd}   & execute command for every cell text & None \\
% \end{spectblr}
\begin{spectblr}[
  caption = {\V{rows}选项的键和键值},
  label = {key:row},
  remark{注意} = {多数情况下，对于带有下划线的键，可以省略键名而只给出键值。}
]{verb}
  % Key & Description and Values & Initial Value \\
  \relax{}键 & \relax{}说明与可选键值 & \relax{}初始值 \\
  \underline{\K{halign}}
       & 水平对齐方式： \V{l} (left), \V{c} (center), \V{r} (right)或\V{j}(justify)
    & \V{j} \\
  \underline{\K{valign}}
    & 垂直对齐方式： \V{t} (top), \V{m} (middle), \V{b} (bottom),
      \V{h} (head) 或 \V{f} (foot)
    & \V{t} \\
  \underline{\K{ht}} & 行高 & \None \\
  \underline{\K{bg}} & 背景颜色 & \None \\
  \K{fg} & 前景颜色 & \None \\
  \K{font} & 字体命令 & \None \\
  \K{mode}  & 行模式: \V{math}, \V{imath}, \V{dmath} or \V{text} & \None \\
  \verb!$!  & 与 \V{mode=math} 相同 & \None \\
  \verb!$$! & 与 \V{mode=dmath} 相同 & \None \\
  \K{cmd}   & 对每个单元格文本要执行的命令 & \None \\
  \K{abovesep} & 行前垂直间距 & \V{2pt} \\
  \K{abovesep+} & 行前垂直间距增量 & \None \\
  \K{belowsep} & 行后垂直间距 & \V{2pt} \\
  \K{belowsep+} & 行后垂直间距增量 & \None \\
  \K{rowsep} & 行前行后垂直间距 & \V{2pt} \\
  \K{rowsep+} & 行前行后垂直间距增量 & \None \\
  \K{preto} & 单元格前导文本(如\K{rowspec}选项中的\V{>}) & \None \\
  \K{appto} & 单元格附加文本(如\K{rowspec}选项中的\V{<}) & \None \\
\end{spectblr}
\vspace{-2em}
% \begin{spectblr}[
%   caption = {Keys for Columns},
%   label = {key:column},
%   remark{Note} = {In most cases, you can omit the underlined key names and write only their values.}
% ]{}
%   Key & Description and Values & Initial Value \\
%   \underline{\K{halign}}
%     & horizontal alignment: \V{l} (left), \V{c} (center), or \V{r} (right)
%     & \V{l} \\
%   \underline{\K{valign}}
%     & vertical alignment: \V{t} (top), \V{m} (middle), \V{b} (bottom),
%       \V{h} (head) or \V{f} (foot)
%     & \V{t} \\
%   \underline{\K{wd}} & width dimension & None \\
%   \underline{\K{co}} & coefficient for the extendable column (\V{X} column) & None \\
%   \underline{\K{bg}} & background color name & None \\
%   \K{fg} & foreground color name & None \\
%   \K{font} & font commands & None \\
%   \K{leftsep} & set horizontal space to the left of the column & \V{6pt} \\
%   \K{leftsep+} & increase horizontal space to the left of the column & None \\
%   \K{rightsep} & set horizontal space to the right of the column & \V{6pt} \\
%   \K{rightsep+} & increase horizontal space to the right of the column & None \\
%   \K{colsep} & set horizontal space to both sides of the column & \V{6pt} \\
%   \K{colsep+} & increase horizontal space to both sides of the column & None \\
%   \K{preto} & prepend text to every cell (like \V{>} specifier in \K{colspec}) & None \\
%   \K{appto} & append text to every cell (like \V{<} specifier in \K{colspec}) & None \\
%   \K{cmd}   & execute command for every cell text & None \\
% \end{spectblr}
\begin{spectblr}[
  caption = {\V{columns}选项的键和键值},
  label = {key:column},
  remark{注意} = {多数情况下，对于带有下划线的键，可以省略键名而只给出键值。}
]{verb}
  % Key & Description and Values & Initial Value \\
  \relax{}键 & \relax{}说明与可选键值 & \relax{}初始值 \\
  \underline{\K{halign}}
    & 水平对齐方式： \V{l} (left)、 \V{c} (center)、 \V{r} (right)或\V{j}(justify)
    & \V{j} \\
  \underline{\K{valign}}
    & 垂直对齐方式： \V{t} (top)、 \V{m} (middle)、 \V{b} (bottom)、
      \V{h} (head)或 \V{f} (foot)
    & \V{t} \\
  \underline{\K{wd}} & 列宽 & \None \\
  \underline{\K{co}} & 可扩展列的扩展系数(\V{X}列) & \None \\
  \underline{\K{bg}} & 背景颜色 & \None \\
  \K{fg} & 前景颜色 & \None \\
  \K{font} & 字体命令 & \None \\
  \K{mode}  & 列模式: \V{math}, \V{imath}, \V{dmath} or \V{text} & \None \\
  \verb!$!  & 与 \V{mode=math} 相同 & \None \\
  \verb!$$! & 与 \V{mode=dmath} 相同 & \None \\
  \K{cmd}   & 对每个单元格文本要执行的命令 & \None \\
  \K{leftsep} & 列左侧水平间距 & \V{6pt} \\
  \K{leftsep+} & 列左侧水平间距增量 & \None \\
  \K{rightsep} & 列右侧水平间距 & \V{6pt} \\
  \K{rightsep+} & 列右侧水平间距增量 & \None \\
  \K{colsep} & 列左右水平间距 & \V{6pt} \\
  \K{colsep+} & 列左右水平间距增量 & \None \\
  \K{preto} & 单元格前导文本(如\K{colspec}选项中的\V{>}) & \None \\
  \K{appto} & 单元格附加文本(如\K{colspec}选项中的\V{<}) & \None \\
\end{spectblr}

% \subsection{Rows and Columns in New Interfaces}
\subsection{行和列设置新接口}

% Options \verb!rows! and \verb!columns! are for setting all rows and columns, respectively.
\verb!rows! 和 \verb!columns! 分别用于设置表格的所有行/列格式。
\nopagebreak
\begin{demohigh}
\begin{tblr}{
 hlines, vlines,
 rows = {7mm}, columns = {15mm,c},
}
 Alpha   & Beta  & Gamma   & Delta \\
 Epsilon & Zeta  & Eta     & Theta \\
 Iota    & Kappa & Lambda  & Mu    \\
\end{tblr}
\end{demohigh}

% Options \verb!row{i}! and \verb!column{j}! are for setting some rows and columns, respectively.
 \verb!row{i}! 和 \verb!column{j}! 键分别用于设置指定行/列格式。

\begin{demohigh}
\begin{tblr}{
 hlines = {1pt,white},
 row{odd} = {blue7},
 row{even} = {azure7},
 column{1} = {purple7,c},
}
 Alpha   & Beta  & Gamma   & Delta   \\
 Epsilon & Zeta  & Eta     & Theta   \\
 Iota    & Kappa & Lambda  & Mu      \\
 Nu      & Xi    & Omicron & Pi      \\
 Rho     & Sigma & Tau     & Upsilon \\
 Phi     & Chi   & Psi     & Omega   \\
\end{tblr}
\end{demohigh}

% The following example demonstrates the usages of \verb!bg!, \verb!fg! and \verb!font! keys.
以下示例演示了 \verb!bg!、 \verb!fg! 和 \verb!font! 键的基本用法：
\nopagebreak
\begin{demohigh}
\begin{tblr}{
 row{odd} = {bg=azure8},
 row{1}   = {bg=azure3, fg=white, font=\sffamily},
}
 Alpha & Beta    & Gamma \\
 Delta & Epsilon & Zeta  \\
 Eta   & Theta   & Iota  \\
 Kappa & Lambda  & Mu    \\
 Nu Xi Omicron & Pi Rho Sigma & Tau Upsilon Phi \\
\end{tblr}
\end{demohigh}

% The following example demonstrates the usages of \verb!mode! key:
以下示例演示了\verb!mode! 键的用法。
\nopagebreak
\begin{demohigh}
$\begin{tblr}{
  column{1} = {mode=text},
  column{3} = {mode=dmath},
}
\hline
  Alpha   & \frac12 & \frac12 \\
  Epsilon & \frac34 & \frac34 \\
  Iota    & \frac56 & \frac56 \\
\hline
\end{tblr}$
\end{demohigh}

% The following example demonstrates the usages of
% \verb!abovesep!, \verb!belowsep!, \verb!leftsep!, \verb!rightsep! keys.
以下示例演示了\verb!abovesep!、 \verb!belowsep!、 \verb!leftsep!、 \verb!rightsep! 键的用法：
%\nopagebreak
\begin{demohigh}
\begin{tblr}{
 hlines, vlines,
 rows = {abovesep=1pt,belowsep=5pt},
 columns = {leftsep=1pt,rightsep=5pt},
}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

% The following example shows that we can replace \verb!\\[dimen]! with \verb!belowsep+! key.
以下示例演示了用\verb!belowsep+! 替代 \verb!\\[dimen]!命令的方法。

\begin{demohigh}
\begin{tblr}{
 hlines, row{2} = {belowsep+=5pt},
}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

% \subsection{Rows and Columns in Old Interfaces}
\subsection{行和列设置旧接口}

% The \verb!\SetRow! command has a mandatory argument for setting the styles of current row.
% The available keys are described in Table \ref{key:row}.
可以通过\verb!\SetRow! 命令的必选参数设置当前行的格式。
其有效值见表 \ref{key:row}.

\begin{demohigh}
\begin{tblr}{llll}
\hline[1pt]
 \SetRow{azure8} Alpha & Beta & Gamma & Delta \\
\hline
 \SetRow{blue8,c} Epsilon & Zeta & Eta & Theta \\
\hline
 \SetRow{violet8} Iota & Kappa & Lambda & Mu \\
\hline[1pt]
\end{tblr}
\end{demohigh}

% In fact, table command \verb!\SetRow{<styles>}! at the beginning of row \verb!i!
% is the same as table option \verb!row{i}={<styles>}!.
本质上，在第\verb!i!行开始的命令\verb!\SetRow{<styles>}!与
keyval \verb!row{i}={<styles>}!的作用相同。

% Also, table command \verb!\SetRows{<styles>}! at the beginning of some row
% is the same as table option \verb!rows={<styles>}!.
另外，在一些行开始的命令\verb!\SetRows{<styles>}!与
keyval \verb!rows={<styles>}!的作用相同。

% The usages of table commands \verb!\SetColumn! and \verb!\SetColumns!
% are similar to those of \verb!\SetRow! and \verb!\SetRows!, respectively.
% But normally you don't need to use them.
\verb!\SetColumn! 和 \verb!\SetColumns!表格命令的用法分别与
\verb!\SetRow! 和 \verb!\SetRows!命令类似。
但一般不直接使用这两个命令。

% \section{Colspec and Rowspec}
\section{\V{colspec}和\V{rowspec}键}

% Options \verb!colspec!/\verb!rowspec! are for setting column/row specifications
% with column/row type specifiers.
\verb!colspec!/\verb!rowspec! 用于使用column/row格式参数设置column/row的格式。

% \subsection{Colspec and Width}
\subsection{\V{colspec}键和\V{width}键}

% Option \verb!width! is for setting the width of the table with extendable columns.
% The following example demonstrates the usage of \verb!width! option.
\verb!width! 用于设置具备可扩展列的表格总宽度。
下面的示例演示了 \verb!width! 的用法:
\nopagebreak
\begin{demohigh}
\begin{tblr}{width=0.8\textwidth, colspec={|l|X[2]|X[3]|X[-1]|}}
 Alpha   & Beta  & Gamma  & Delta \\
 Epsilon & Zeta  & Eta    & Theta \\
 Iota    & Kappa & Lambda & Mu    \\
\end{tblr}
\end{demohigh}

% You can omit \verb!colspec! name if it is the only key you use inside the mandatory argument.
% The following example demonstrates the usages of \verb!$! and \verb!$$! keys:
如果在必选参数使用唯一的键，则可以省略\verb!colspec!名称。
下面的示例演示了 \verb!$! 的用法:
\nopagebreak
\begin{demohigh}
\begin{tblr}{Q[l]Q[r,$]Q[r,$$]}
\hline
  Alpha   & \frac12 & \frac12 \\
  Epsilon & \frac34 & \frac34 \\
  Iota    & \frac56 & \frac56 \\
\hline
\end{tblr}
\end{demohigh}

% \subsection{Column Types}
\subsection{列格式}

% The \verb!tabularray! package has only one type of primitive column: the \verb!Q! column.
% Other types of columns are defined as \verb!Q! columns with some keys.
\verb!Tabularray! 宏包仅设计了一个列格式的\verb!Q! 元格式。
其它的列格式都是通过为\verb!Q! 元格式指定不同的参数实现定义。

\begin{codehigh}
\NewColumnType{l}{Q[l]}
\NewColumnType{c}{Q[c]}
\NewColumnType{r}{Q[r]}
\NewColumnType{t}[1]{Q[t,wd=#1]}
\NewColumnType{m}[1]{Q[m,wd=#1]}
\NewColumnType{b}[1]{Q[b,wd=#1]}
\NewColumnType{h}[1]{Q[h,wd=#1]}
\NewColumnType{f}[1]{Q[f,wd=#1]}
\NewColumnType{X}[1][]{Q[co=1,#1]}
\end{codehigh}

\begin{demohigh}
\begin{tblr}{|t{15mm}|m{15mm}|b{20mm}|}
 Alpha   & Beta  & {Gamma\\Gamma} \\
 Epsilon & Zeta  & {Eta\\Eta} \\
 Iota    & Kappa & {Lambda\\Lambda} \\
\end{tblr}
\end{demohigh}

% Any new column type must be defined with \verb!\NewColumnType! command.
% It can have an optional argument when it's defined.
任何新的列格式都需要使用 \verb!\NewColumnType! 命令定义。
在定义时，可以使用可选参数。

% \subsection{Row Types}
\subsection{行格式}

% The \verb!tabularray! package has only one type of primitive row: the \verb!Q! row.
% Other types of rows are defined as \verb!Q! rows with some keys.
同样，\verb!Tabularray! 宏包仅设计了一个行格式的\verb!Q! 元格式。
其它的行格式都是通过为\verb!Q! 元格式指定不同的参数实现定义。

\begin{codehigh}
\NewRowType{l}{Q[l]}
\NewRowType{c}{Q[c]}
\NewRowType{r}{Q[r]}
\NewRowType{t}[1]{Q[t,ht=#1]}
\NewRowType{m}[1]{Q[m,ht=#1]}
\NewRowType{b}[1]{Q[b,ht=#1]}
\NewRowType{h}[1]{Q[h,ht=#1]}
\NewRowType{f}[1]{Q[f,ht=#1]}
\end{codehigh}

\begin{demohigh}
\begin{tblr}{rowspec={|t{12mm}|m{10mm}|b{10mm}|}}
 Alpha   & Beta  & {Gamma\\Gamma} \\
 Epsilon & Zeta  & {Eta\\Eta} \\
 Iota    & Kappa & {Lambda\\Lambda} \\
\end{tblr}
\end{demohigh}

% Any new row type must be defined with \verb!\NewRowType! command.
% It can have an optional argument when it's defined.
任何新的行格式都需要使用 \verb!\NewRowType! 命令定义。
在定义时，可以使用可选参数。

\end{document}
